<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>机构管理</title>
<!-- 	<meta name="decorator" content="default"/> -->
	<%@include file="/WEB-INF/views/include/head.jsp" %>
	<%@include file="/WEB-INF/views/include/treeview.jsp" %>
	<link href="${ctxStatic}/sidemenu/css/BootSideMenu.css" rel="stylesheet" type="text/css"/>
	<script type="text/javascript" src="${ctxStatic}/sidemenu/BootSideMenu.js"></script>
	<style type="text/css">
		.ztree {overflow:hidden;margin:0;margin-top:10px;padding:10px 0 0 10px;}
		.panel{margin-bottom: 0}
		.container-fluid{padding: 5px 0 0 5px}
		.panel-body{padding: 0;overflow-y: auto;}
		.col-md-3{padding-right: 0;max-width: 400px}
		.col-md-12{padding-left: 10px;}
	</style>
</head>
<body>
	<sys:message content="${message}"/>
	<div class="container-fluid">
		<div class="row" style="height: 100%">
			<div class="col-md-3" id="leftTree">
				<div class="panel panel-default" id="mypanel">
  					<div class="panel-heading">组织机构<i class="fa fa-refresh pull-right" style="cursor: pointer;" onclick="refreshTree();"></i></div>
 					<div class="panel-body">
						<div id="ztree" class="ztree"></div>
					</div>
					<!-- <div id="openClose" class="close" style="height: 496px;">&nbsp;</div> -->
				</div>
			</div>
			<div class="col-md-12" id="rightContent">
				<iframe id="officeContent" src="${ctxAdmin}/sys/office/list" width="100%" frameborder="0" style="overflow: hidden;"></iframe>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'0'}},
			callback:{onClick:function(event, treeId, treeNode){
				//var id = treeNode.pId == '1' ? '' :treeNode.pId;
				var id = treeNode.id == '1' ? '' :treeNode.id;
				var d =  new Date();
				var  r= d.getTime();
				$('#officeContent').attr("src","${ctxAdmin}/sys/office/list?id="+id+"&r="+r);
				}
			}
		};
		
		function refreshTree(){
			$.getJSON("${ctxAdmin}/sys/office/treeData",function(data){
				$.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
			});
		}
		$(function(){
			resize();
			refreshTree();
			$(window).resize(function(){resize();});
			$('#leftTree').BootSideMenu({
		        side: "left",
		        width:'220px',
		        remember:false,
		        onOpen: function () {
		        	$('#rightContent').attr('style','padding-left:10px');
		        },
		        onClose: function () {
					$('#rightContent').attr('style','padding-left:27px');
		        }
		    });
		});
		function resize(){
			var height=defaultHeight-10;
			var leftW=$('.col-md-3').width();
			var width=defaultWidth-leftW;
			$('#officeContent').height(height);
			$('#mypanel').height(height);
			if(height<550)$('.panel-body').height(height*0.9);
		}
		
	</script>
</body>
</html>